package com.metronoteapp.dialog;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.provider.Settings;
import android.view.View;
import com.metronoteapp.MainActivity;
import com.metronoteapp.R;
import com.metronoteapp.until.GlobalVariable;


public class ShowDialog extends View
{
	private Context mContext;
	private AlertDialog.Builder builder;

	public ShowDialog(Context context)
	{
		super(context);
		mContext = context;
	}


	public void loginfailure()
	{
		builder = new AlertDialog.Builder(mContext);
		builder.setTitle(mContext.getString(R.string.msg_login_title));
		String message = "Error";
//		if(GlobalVariable.getErrorMessage() != null && !GlobalVariable.getErrorMessage().equals(""))
//		{
//			message = GlobalVariable.getErrorMessage();
//		}
		builder.setMessage(message)
		.setNegativeButton(mContext.getString(R.string.cancel), new DialogInterface.OnClickListener()
		{
			public void onClick(DialogInterface dialog, int id)
			{
				dialog.cancel();
			}
		});
		builder.show();
	}

	public void function(final Context mContext, final int _screen, final int _isfinish)
	{
		builder = new AlertDialog.Builder(mContext);
		builder.setMessage("Are you sure")
		.setPositiveButton(mContext.getString(R.string.ok), new DialogInterface.OnClickListener()
		{
			public void onClick(DialogInterface dialog, int id)
			{


			}
		})
		.setNegativeButton(mContext.getString(R.string.cancel), new DialogInterface.OnClickListener()
		{
			public void onClick(DialogInterface dialog, int id)
			{
				dialog.cancel();
			}
		});
		builder.show();
	}
	
	public void settingNetwork()
	{
		builder = new AlertDialog.Builder(mContext);
		builder.setTitle(R.string.msg_setting_network_title);
		builder.setMessage(R.string.msg_setting_network_content)
		.setPositiveButton(R.string.settings, new DialogInterface.OnClickListener()
		{
			public void onClick(DialogInterface dialog, int id)
			{
				Intent myIntent = new Intent(Settings.ACTION_SETTINGS);
				mContext.startActivity(myIntent);
			}
		})
		.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener()
		{
			public void onClick(DialogInterface dialog, int id)
			{
				dialog.cancel();
			}
		});
		builder.show();
	}

	public void exitApp()
	{
		builder = new AlertDialog.Builder(mContext);
		builder.setTitle(R.string.msg_exit_title);
		builder.setMessage(R.string.msg_exit_message)
		.setPositiveButton(R.string.msg_no_button_text, new DialogInterface.OnClickListener()
		{
			public void onClick(DialogInterface dialog, int id)
			{
				dialog.cancel();
				
			}
		})
		.setNegativeButton(R.string.msg_yes_button_text, new DialogInterface.OnClickListener()
		{
			public void onClick(DialogInterface dialog, int id)
			{
				((MainActivity)mContext).finish();
			}
		});
		builder.show();
	}

	public void notRecord(String title)
	{
		builder = new AlertDialog.Builder(mContext);
		builder.setTitle(title);
		builder.setMessage("0 record")
		.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener()
		{
			public void onClick(DialogInterface dialog, int id)
			{
				dialog.cancel();
			}
		});
		builder.show();
	}

	public void errorMessage(String title)
	{
		builder = new AlertDialog.Builder(mContext);
		builder.setTitle(title);
		builder.setMessage(GlobalVariable.getErrorMessage())
		.setNegativeButton(mContext.getString(R.string.cancel), new DialogInterface.OnClickListener()
		{
			public void onClick(DialogInterface dialog, int id)
			{
				dialog.cancel();
			}
		});
		builder.show();
	}
}